package router

import (
	"github.com/gin-gonic/gin"
	"micro-store/middleware"
	"micro-store/service"
)

/**
 * @Description 路由
 * @Date 2023/5/13 周六 19:16
 * @Author Tang-J-L <vx：17685112557>
 */

func Router() *gin.Engine {
	router := gin.Default()
	router.Use(middleware.Cors()) // 允许跨域
	api := router.Group("/api")
	user := api.Group("/user")
	{
		user.GET("/list", service.GetUserList)
		user.POST("/create", service.CreateUser)
		user.POST("/check", service.CheckName)
		user.POST("/login", service.UserLogin)
		user.DELETE("/delete", service.UserDelete)
		user.PUT("/update", service.UserUpdate)
	}
	return router
}
